package secondStage.part2.Object;

/**
 * @ClassName: [Object_learn]
 * @Description: Object类学习equals方法
 * @Author: [黄劲松]
 * @CreateDate: [2021-03-28]
 * @Version: [v1.0]
 */
public class Object_learn1 {
    public static void main(String[] args) {
        Student student = new Student();
        student.setName("郑武家");
        student.setAge(33);
        //比较两个对象内容是否相容
        Student student1 = new Student();
        student1.setName("郑武家");
        student1.setAge(33);
        //将会输出false，== 比较的是地址
        System.out.println(student == student1);
        //equals方法没有重写时，将会输出false，比较的是地址值所以不同
        System.out.println(student.equals(student1));
        //equals默认比较的是地址，需要重写equals方法，才能比较比较两个对象内容是否相容
        System.out.println(student.equals(student1));
    }
}
